/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.ufpb.halloc.negocio;

import br.com.ufpb.halloc.dados.TurmaDAO;
import br.com.ufpb.halloc.dados.TurmaDAOBin;
import br.com.ufpb.halloc.dados.TurmaDAOFactory;
import br.com.ufpb.halloc.dados.TurmaDAOBDFactory;
import br.com.ufpb.halloc.dados.TurmaDAOPostgreSQL;
import br.com.ufpb.halloc.exceptions.AtualizacaoDeTurmaException;
import br.com.ufpb.halloc.exceptions.TurmaInexistenteException;
import br.com.ufpb.halloc.exceptions.TurmaInvalidaException;
import br.com.ufpb.halloc.exceptions.TurmaVaziaException;
import br.com.ufpb.halloc.negocio.Turma;
import java.util.List;

/**
 *
 * @author Rennan
 */
public class GerenteDeCadastroTurma {
    
    private TurmaDAOFactory turmaF = TurmaDAOFactory.getTurmaDAOFactory(TurmaDAOFactory.BD);
    private TurmaDAOPostgreSQL turmaDAO;
    
    public GerenteDeCadastroTurma(){
        turmaDAO = (TurmaDAOPostgreSQL)turmaF.getTurmaDAO(TurmaDAOBDFactory.PGSQL);
    }
    
    public void addTurma(Turma t) throws TurmaInvalidaException{
        turmaDAO.insert(t);
    }
    
    public Turma getTurma(String id) throws TurmaInexistenteException{
        return turmaDAO.findID(id);
    }
    
    public List<Turma> getTurmaNome(String nome) throws TurmaInexistenteException{
        return turmaDAO.getTurma(nome);
    }
    
    public List<Turma> getTurmas(){
        return turmaDAO.getTurmas();
    }
    
    public void removerTurma(Turma t) throws TurmaInexistenteException, TurmaVaziaException{
        turmaDAO.delete(t);
    }
    
    public void removerTurma(String id) throws TurmaInexistenteException, TurmaVaziaException{
        turmaDAO.delete(turmaDAO.findID(id));
    }
    
    public void atualizarTurma(Turma t) throws AtualizacaoDeTurmaException{
        turmaDAO.update(t);
    }
    
    public int size(){
        return turmaDAO.size();
    }
    
    public List<Turma> turmasAlocadas(){
        return turmaDAO.turmasAlocas();
    }

    public List<Turma> turmasAbertas(){
        return turmaDAO.turmasabertas();
    }
}

